﻿using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace netRecord
{
    public class SqlDbContext:DbContext
    {
        private static ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());
        public DbSet<StudentEntity> Students { get; set; }
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);
            optionsBuilder.UseSqlServer("server=localhost;database=db0805;integrated security= true; encrypt=false;");
            optionsBuilder.UseLoggerFactory(loggerFactory);
        }


        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.ApplyConfigurationsFromAssembly(this.GetType().Assembly);
        }
    }
}
